#include "menu.h"
#include "ui_menu.h"

Menu::Menu(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Menu)
{
    ui->setupUi(this);

    QString itemName[] = {"网易云音乐","天气预报"};

    int row = 0;
    //把字符串数组作为选项加入到列表界面中
    for (QString var : itemName) {
      //  QListWidgetItem *newItem = new QListWidgetItem;//创建一个列表项
        //在row行插入选项，选项的文本是字符串变量var
        ui->listWidget->insertItem(row, var);
        row++;
    }

    pMusic= new music(ui->frame);

    pWeather =new weatherSearch(ui->frame);
    pWeather->hide();
}

Menu::~Menu()
{
    delete ui;
}



void Menu::on_listWidget_currentRowChanged(int currentRow)
{
    if(currentRow==0)
    {
        pMusic->show();
        pWeather->hide();
    }
    else if(currentRow==1)
    {
        pWeather->show();
        pMusic->hide();
    }else if(currentRow==3)
    {
        pWeather->hide();
        pMusic->hide();
    }
}

